package com.usian.common.execption;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice //监听所有controller层异常信息
@Log4j2
public class ExecptionCatch {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseResult exception(Exception e){
        log.info("我是统一异常处理类，遇到的错误是："+e);
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
}
